/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Interface.Despesa.Apresentador;

import Interface.Despesa.Apresentador.*;
import static Interface.Global.aux;
import Modelo.DespesaApresentador.DespesaApresentador;
import Modelo.Edicao.Edicao;
import Modelo.Evento.Evento;
import Modelo.Patrocinio.Patrocinio;
import Util.ExcecaoNaoApresentador;

import java.awt.Component;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author ana.siena
 */
public class CriarDespesaApresentador extends javax.swing.JFrame {

    private long codDespesa;
    private long codEvento;
    private int numeroEdicao; 
    private String CNPJPatroc; 
    private Long codEventoPatroc;
    private int nroEdicaoPatroc;
    private DespesaApresentador despesa;
    private Calendar dataDespesa;
    private float valorDespesa;
    private String descricaoDespesa;
    private String tipoDespesa;
    private long codEven;
    private DespesaApresentador despesaInserir;
    private int nroInsc;
    private int nroEdi;
    private long codEven2;
    private int nroEdi2;
    private String CNPJescrever;
    private int NroInsc;
        
    public CriarDespesaApresentador() {
        initComponents();
        init();
    }
    
    private void init(){
	setVisible(true);
        setTitle("Atualizar Despesas");
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //Preenche combobox do evento
        ArrayList <Evento> vetorCodEvento = new ArrayList <Evento>();
        vetorCodEvento = (ArrayList<Evento>) aux.buscarTodosEventos();
        
        for(int i=0; i<vetorCodEvento.size();i++)
        {
            codEventoCombo.addItem(vetorCodEvento.get(i).getCodEvento());
        }
        
        //Preenche combobox do evento Patrocinador
        ArrayList <Evento> vetorCodEventoPatroc = new ArrayList <Evento>();
        vetorCodEventoPatroc = (ArrayList<Evento>) aux.buscarTodosEventos();
        
        for(int i=0; i<vetorCodEvento.size();i++)
        {
            codEventoPatrociCombo.addItem(vetorCodEvento.get(i).getCodEvento());
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel4 = new javax.swing.JLabel();
        codEventoCombo1 = new javax.swing.JComboBox();
        nroEdicaoCombo1 = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        nroInscrito3 = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        CNPJPatrocionio = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        codEventoCombo = new javax.swing.JComboBox();
        nroEdicaoCombo = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        data2 = new javax.swing.JTextField();
        valor2 = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        tipoDesp2 = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        descricao2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        codEventoPatrociCombo = new javax.swing.JComboBox();
        nroEdicaoPatroCombo = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        nroInscrito4 = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        CNPJPatrocionio1 = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        botaoCriar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        botaoRetornar = new javax.swing.JButton();

        jLabel4.setText("Codigo do evento:");

        codEventoCombo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                codEventoCombo1ActionPerformed(evt);
            }
        });

        nroEdicaoCombo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroEdicaoCombo1ActionPerformed(evt);
            }
        });

        jLabel5.setText("Nro da Edicao:");

        nroInscrito3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroInscrito3ActionPerformed(evt);
            }
        });

        jLabel20.setText("Nro. Inscr. Apres.:");

        jLabel8.setText("CNPJ do Patrocinador:");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados para busca"));

        jLabel2.setText("Codigo do evento:");

        jLabel3.setText("Nro da Edicao:");

        codEventoCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                codEventoComboActionPerformed(evt);
            }
        });

        nroEdicaoCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroEdicaoComboActionPerformed(evt);
            }
        });

        jLabel15.setText("Data:");

        data2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                data2ActionPerformed(evt);
            }
        });

        valor2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                valor2ActionPerformed(evt);
            }
        });

        jLabel16.setText("Valor:");

        jLabel17.setText("Tipo de despesa:");

        tipoDesp2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tipoDesp2ActionPerformed(evt);
            }
        });

        jLabel19.setText("Descricao:");

        descricao2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descricao2ActionPerformed(evt);
            }
        });

        jLabel6.setText("Codigo even. Patrocin.:");

        codEventoPatrociCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                codEventoPatrociComboActionPerformed(evt);
            }
        });

        nroEdicaoPatroCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroEdicaoPatroComboActionPerformed(evt);
            }
        });

        jLabel7.setText("Nro da Edicao Patrocin.:");

        nroInscrito4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroInscrito4ActionPerformed(evt);
            }
        });

        jLabel21.setText("Nro. Inscr. Apres.:");

        CNPJPatrocionio1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CNPJPatrocionio1ActionPerformed(evt);
            }
        });

        jLabel9.setText("CNPJ do Patrocinador:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel19)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
                                .addComponent(descricao2, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel17)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel15)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLabel16)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(valor2, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(tipoDesp2, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jLabel2)
                                                .addGap(49, 49, 49)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(codEventoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(nroEdicaoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(data2, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(26, 26, 26))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel21)
                            .addComponent(jLabel9))
                        .addGap(22, 22, 22)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(codEventoPatrociCombo, 0, 123, Short.MAX_VALUE)
                            .addComponent(nroEdicaoPatroCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(nroInscrito4)
                            .addComponent(CNPJPatrocionio1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(codEventoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(nroEdicaoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(codEventoPatrociCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(nroEdicaoPatroCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(CNPJPatrocionio1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(nroInscrito4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(data2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16)
                    .addComponent(valor2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(tipoDesp2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(descricao2, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        botaoCriar.setText("Criar");
        botaoCriar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoCriarActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Criar uma Despesa para um Apresentador");

        botaoRetornar.setText("Retornar");
        botaoRetornar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoRetornarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(botaoRetornar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botaoCriar))
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(68, 68, 68)
                        .addComponent(jLabel1)))
                .addContainerGap(31, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(41, 41, 41))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(415, 415, 415)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(botaoCriar)
                            .addComponent(botaoRetornar))
                        .addContainerGap())))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoRetornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoRetornarActionPerformed
        new MenuDespesaApresentador().setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_botaoRetornarActionPerformed

    private void botaoCriarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoCriarActionPerformed
        codEven = Long.parseLong(""+ codEventoCombo.getSelectedItem());
        nroEdi = Integer.parseInt(""+ nroEdicaoCombo.getSelectedItem());
        nroEdi2 = Integer.parseInt(""+nroEdicaoPatroCombo.getSelectedItem());
        codEven2 = Long.parseLong(""+ codEventoPatrociCombo.getSelectedItem());
        
        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        this.dataDespesa  = Calendar.getInstance();
        try {
            this.dataDespesa.setTime(df.parse(this.data2.getText()));
        } catch (ParseException ex) {
            Logger.getLogger(CriarDespesaApresentador.class.getName()).log(Level.SEVERE, null, ex);
            Component frame = null;
            JOptionPane.showMessageDialog(frame,ex.getMessage());
        }
                
        this.descricaoDespesa = descricao2.getText();
        this.valorDespesa = Float.valueOf(valor2.getText());
        this.tipoDespesa = tipoDesp2.getText();
        CNPJescrever = (String) CNPJPatrocionio1.getSelectedItem();              
        nroInsc = Integer.parseInt(nroInscrito4.getText());
        
        System.out.println("Passei por aqui 1!");
        despesaInserir = new DespesaApresentador (nroEdi,CNPJescrever, codEven2, nroEdi2, dataDespesa, valorDespesa, descricaoDespesa, tipoDespesa, codEven, nroInsc);
        System.out.println("Passei por aqui 2!");
        try {
            System.out.println("Passei por aqui 3!");
            aux.adicionaDespesaApresentador(despesaInserir);
            System.out.println("Passei por aqui 4!");
	} catch (ExcecaoNaoApresentador e) {
            Logger.getLogger(ConsultarDespesaApresentador.class.getName()).log(Level.SEVERE, null, e);
            Component frame = null;
            JOptionPane.showMessageDialog(frame,e.getMessage());
        }
        
    }//GEN-LAST:event_botaoCriarActionPerformed

    private void nroEdicaoComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroEdicaoComboActionPerformed
        codEven = Long.parseLong(""+ codEventoCombo.getSelectedItem());
        nroEdi = Integer.parseInt(""+ nroEdicaoCombo.getSelectedItem());
        
        //Preenche combobox do CNPJ patrocinador
        ArrayList <Patrocinio> vetorCNPJ = new ArrayList <Patrocinio>();
        vetorCNPJ = (ArrayList<Patrocinio>) aux.buscarCNPJPatrocinioPorEDICAOeEVENTO(codEven, nroEdi);
        
        for(int i=0; i<vetorCNPJ.size();i++)
        {
            CNPJPatrocionio.addItem(vetorCNPJ.get(i).getCnpjPatrocinador());
        }
    }//GEN-LAST:event_nroEdicaoComboActionPerformed

    private void codEventoComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codEventoComboActionPerformed
        codEven = Long.parseLong(""+ codEventoCombo.getSelectedItem());

        if(codEven == 0){
            System.out.println("Não tem nenhum evento selecionado");
        }
        else{
            //Preenche combobox do edicao
            ArrayList <Edicao> vetorCodEdicao = new ArrayList <Edicao>();
            vetorCodEdicao = (ArrayList<Edicao>) aux.buscaEdicoesPorEvento(codEven);

            nroEdicaoCombo.removeAllItems();
            for(int i=0; i<vetorCodEdicao.size();i++)
            {
                nroEdicaoCombo.addItem(vetorCodEdicao.get(i).getNroEdicao());
            }
        }
    }//GEN-LAST:event_codEventoComboActionPerformed

    private void data2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_data2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_data2ActionPerformed

    private void valor2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_valor2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_valor2ActionPerformed

    private void tipoDesp2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tipoDesp2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tipoDesp2ActionPerformed

    private void descricao2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descricao2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_descricao2ActionPerformed

    private void codEventoCombo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codEventoCombo1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_codEventoCombo1ActionPerformed

    private void nroEdicaoCombo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroEdicaoCombo1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nroEdicaoCombo1ActionPerformed

    private void codEventoPatrociComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codEventoPatrociComboActionPerformed
        codEven2 = Long.parseLong(""+ codEventoPatrociCombo.getSelectedItem());

        if(codEven2 == 0){
            System.out.println("Não tem nenhum evento selecionado");
        }
        else{
            //Preenche combobox do edicao
            ArrayList <Edicao> vetorCodEdicao = new ArrayList <Edicao>();
            vetorCodEdicao = (ArrayList<Edicao>) aux.buscaEdicoesPorEvento(codEven);

            nroEdicaoPatroCombo.removeAllItems();
            for(int i=0; i<vetorCodEdicao.size();i++)
            {
                nroEdicaoPatroCombo.addItem(vetorCodEdicao.get(i).getNroEdicao());
            }
        }
    }//GEN-LAST:event_codEventoPatrociComboActionPerformed

    private void nroEdicaoPatroComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroEdicaoPatroComboActionPerformed
        System.out.println("Passei por aqui 0!");
        
        nroEdi2 = Integer.parseInt(""+nroEdicaoPatroCombo.getSelectedItem());
        codEven2 = Long.parseLong(""+ codEventoPatrociCombo.getSelectedItem());
        
        if(nroEdi2 == 0){
            System.out.println("Não tem nenhum evento selecionado");
        }
        else{

            ArrayList <Patrocinio> vetorCNPJ = new ArrayList <Patrocinio>();
            vetorCNPJ = (ArrayList<Patrocinio>) aux.buscarCNPJPatrocinioPorEDICAOeEVENTO(codEven2,nroEdi2);
                   
            CNPJPatrocionio1.removeAllItems();
            for(int i=0; i<vetorCNPJ.size();i++)
            {    
                CNPJPatrocionio1.addItem(vetorCNPJ.get(i).getCnpjPatrocinador());
            }
        }
    }//GEN-LAST:event_nroEdicaoPatroComboActionPerformed

    private void nroInscrito3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroInscrito3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nroInscrito3ActionPerformed

    private void nroInscrito4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroInscrito4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nroInscrito4ActionPerformed

    private void CNPJPatrocionio1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CNPJPatrocionio1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CNPJPatrocionio1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox CNPJPatrocionio;
    private javax.swing.JComboBox CNPJPatrocionio1;
    private javax.swing.JButton botaoCriar;
    private javax.swing.JButton botaoRetornar;
    private javax.swing.JComboBox codEventoCombo;
    private javax.swing.JComboBox codEventoCombo1;
    private javax.swing.JComboBox codEventoPatrociCombo;
    private javax.swing.JTextField data2;
    private javax.swing.JTextField descricao2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JComboBox nroEdicaoCombo;
    private javax.swing.JComboBox nroEdicaoCombo1;
    private javax.swing.JComboBox nroEdicaoPatroCombo;
    private javax.swing.JTextField nroInscrito3;
    private javax.swing.JTextField nroInscrito4;
    private javax.swing.JTextField tipoDesp2;
    private javax.swing.JTextField valor2;
    // End of variables declaration//GEN-END:variables
}
